import java.io.IOException;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 19182
 * Date: 2025-09-21
 * Time: 21:05
 */
public class TcpDictServer extends TcpEchoServer{
    private HashMap<String, String> hash = new HashMap<>();
    public TcpDictServer(int port) throws IOException {
        super(port);
        hash.put("hello", "你好");
        hash.put("world", "世界");
        hash.put("cat", "小猫");
        hash.put("dog", "小狗");
        hash.put("pig", "小猪");
    }
    public String process(String request){
        return hash.getOrDefault(request, "没有找到该单词");
    }

    public static void main(String[] args) throws IOException {
        TcpDictServer tcpDictServer = new TcpDictServer(9090);
        tcpDictServer.start();
    }

}
